<template>
  <div class="mod-config">
    <el-tree
      :data="treeData"
      :props="defaultProps"
      node-key="id"
      ref="goodsCatalogTree"
      @current-change="handleNodeClick"
      :default-expand-all="true"
      :highlight-current="true"
      :expand-on-click-node="false"></el-tree>
  </div>
</template>

<script>
  import goodsCategoryApi from '@/api/goodsCategory'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        treeData: [],
        defaultProps: {
          children: 'children',
          label: 'label'
        }
      }
    },
    mounted () {
      this.getTreeList()
    },
    methods: {
      handleNodeClick (data, node) {
        this.$emit('select-change', data, node)
      },
      getTreeList () {
        goodsCategoryApi.getTreeList(0).then(({data}) => {
          if (data && data.code === 0) {
            this.treeData = data.goodsTree
          }
        })
      }
    }
  }
</script>
